#include"Channel.hpp"
#include"ProcessPool.hpp"
#include<string>
void task1(){
    std::cout<<"task1"<<std::endl;
}
void task2(){
    std::cout<<"task2"<<std::endl;
}
void task3(){
    std::cout<<"task3"<<std::endl;
}
void task4(){
    std::cout<<"task4"<<std::endl;
}
TaskManager taskManager;
void Work(){
    while(true){
        int s;
        //读取管道内的信息
        int sz=read(0,&s,4);
        if(sz>0){
            taskManager.tasks[s]();
        }
        else if(sz==0){
            break;
        }
        sleep(1);
    }
}
int main(){
    srand(time(NULL));
    taskManager.AddTask(task1);
    taskManager.AddTask(task2);
    taskManager.AddTask(task3);
    taskManager.AddTask(task4);
    ProcessPool pool(2,Work);
    pool.DispatchTask();
    return 0;
}